<template>
    <ul>
        <li v-for="item in contentlist" :key="item.id">
            <h3>评论人:{{ item.name }}</h3>
            <p>评论内容:{{ item.content }}</p>
        </li>
    </ul>
</template>
<script>
import eventbus from './eventbus';
export default {
    data() {
        return {
            contentlist: [
                { id: 1, name: '张三', content: '1111111111' },
                { id: 2, name: '李四', content: '2222222222' }
            ]
        }
    },
    mounted() {

        eventbus.on('myevent', ({ person, content }) => {
            // console.log('data', data);
            this.contentlist.unshift({
                id: this.contentlist[0].id - 1,
                name: person,
                content
            })

        })
    }
}
</script>
<style scoped></style>